<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class AdminInstall extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'admin:install {--f|force}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '初始化，生成管理员用户、菜单、权限和角色';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->info('正在生成菜单...');
        $this->call('admin:menus');
        $this->info('菜单完成'.PHP_EOL);

        $this->info('正在初始化权限...');
        $this->call('admin:permissions', [
            '-f' => $this->option('force'),
        ]);
        $this->info('权限完成'.PHP_EOL);

        $this->info('正在初始化角色...');
        $this->call('admin:roles', [
            '-f' => $this->option('force'),
        ]);
        $this->info('角色完成'.PHP_EOL);
    }
}
